#ifndef PP_TAGS_H
#define PP_TAGS_H

#include <string>
#include <map>
#include <cstdint>

namespace pp
{
    class TagParser
    {
    private:
        typedef void (TagParser::*FUNCTAGSSTATE)(uint32_t pos, char ch, const std::string& data);
    private:
        uint32_t m_u32Pos;
        std::string m_sName;
        FUNCTAGSSTATE m_fnState;       // 状态处理函数
        std::map<std::string, std::string> m_oTags;
    public:
        TagParser();

        // 解析字符串
        void Parse(const std::string& data, std::map<std::string, std::string>& attrs);
    private:
        void Reset(); // 重置数据
        void OnTagStateInit(uint32_t pos, char ch, const std::string& data);
        void OnTagStateValue(uint32_t pos, char ch, const std::string& data);
        void OnTagStateValueEnd(uint32_t pos, char ch, const std::string& data);
        void ParseTags(std::map<std::string, std::string>& attrs);
        void ParseJsonTags(const std::string& s, std::map<std::string, std::string>& attrs);
        void ParsePPTags(const std::string& s, std::map<std::string, std::string>& attrs);
    };
};

#endif
